package com.example.Laboratory.Controller;

import com.example.Laboratory.Entity.Notice;
import com.example.Laboratory.Service.NoticeService;
import com.example.Laboratory.Untils.ResultCode;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.io.IOException;

@Api(value = "Notice", description = "通知公告")
@RestController
@RequestMapping(value = "/Notice")
@CrossOrigin
public class NoticeController {

    @Autowired
    NoticeService noticeService1;

    @ApiOperation(value = "添加通知公告", notes = "添加通知公告")
    @RequestMapping(value = "/addNotice", method = RequestMethod.POST, produces = "application/json;charset=utf-8")
    public Object addNotice (Notice i) throws IOException {
        return ResultCode.SUCCESS.result(noticeService1.addNotice(i));
    }

    @ApiOperation(value = "删除通知公告", notes = "删除通知公告")
    @RequestMapping(value = "/deleteNotice", method = RequestMethod.GET, produces = "application/json;charset=utf-8")
    public Object deleteNotice (@RequestParam int notice_id) throws IOException {
        return ResultCode.SUCCESS.result(noticeService1.deleteNotice(notice_id));
    }


    @ApiOperation(value = "单条查找通知公告", notes = "单条查找通知公告")
    @RequestMapping(value = "/researchNotice1", method = RequestMethod.POST, produces = "application/json;charset=utf-8")
    public Object researchNotice1 (int notice_id) throws IOException {
        return ResultCode.SUCCESS.result(noticeService1.researchNotice1(notice_id));
    }

    @ApiOperation(value = "多条查找通知公告", notes = "多条查找通知公告")
    @RequestMapping(value = "/researchNotice2", method = RequestMethod.GET, produces = "application/json;charset=utf-8")
    public Object researchNotice2 ( ) throws IOException {
        return ResultCode.SUCCESS.result(noticeService1.researchNotice2());
    }

    @ApiOperation(value = "修改通知公告", notes = "修改通知公告")
    @RequestMapping(value = "/reviseNotice", method = RequestMethod.POST, produces = "application/json;charset=utf-8")
    public Object reviseNotice (Notice i) throws IOException {
        return ResultCode.SUCCESS.result(noticeService1.reviseNotice(i));
    }
}
